package com.blog.cloud.security.component;

import com.blog.cloud.cache.utils.RedisUtil;
import com.blog.cloud.security.bo.UserInfo;
import lombok.RequiredArgsConstructor;

import java.util.concurrent.TimeUnit;

@RequiredArgsConstructor
public class RedisTokenStore {
    private final RedisUtil redisUtil;

    public UserInfo getUserInfo(String token) {
        return (UserInfo) redisUtil.get(token);
    }

    public void setUserInfo(String token, UserInfo userInfo, Long expire, TimeUnit timeUnit) {
        redisUtil.set(token, userInfo, expire, timeUnit);
    }

    public void removeUserInfo(String token) {
        redisUtil.remove(token);
    }

}
